﻿var chatGroup;
var chatGroupCount=0;

function AddToChatGroup(client,chatId,userInfo){
	client.chatId=chatId;
//	MyTrace(userInfo)
	
	if(chatGroup==undefined){
		chatGroup={};
	}
	if(chatGroup[chatId]==undefined){
		chatGroup[chatId]=CG_initGroup(chatId);
		chatGroupCount++;
		trace("group count:"+chatGroupCount);
	}
	
	
	application.acceptConnection(client);
	
	
	var CG=chatGroup[chatId];
	var info=new Object();
	info.client=client;
	info.CG=CG;
	info.username=userInfo[0];
	info.nickname=userInfo[1];
	info.copId=userInfo[2];
	CG.addUser(info);
	
	client.info=info;
}

function DelFromChatGroup(client){
	client.info.CG.delUser(client);
}